package com.njitt.bysj.controller;

import com.njitt.bysj.base.BaseController;
import com.njitt.bysj.base.ResultInfo;
import com.njitt.bysj.bean.WarehouseBean;
import com.njitt.bysj.query.WarehouseQuery;
import com.njitt.bysj.srevice.WarehouseBeanService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @description:
 * @author: wyj
 * @time: 2022/4/18 12:40
 */
@Controller
@RequestMapping("warehouse")
public class WareHouseController extends BaseController {

    @Resource
    private WarehouseBeanService warehouseBeanService;

    @RequestMapping("toWareHousePage")
    public String toWareHousePage() {
        return "warehouse/warehousePage";
    }

    @RequestMapping("selectByParamsList")
    @ResponseBody
    public Map<String, Object> selectByParamsList(WarehouseQuery query) {
        return warehouseBeanService.selectByParamsList(query);
    }

    @RequestMapping("materialEntryHistory")
    public String entryHistory() {
        /**
         * @description: 采购入库历史
         * @return:  * @param
         * @author:
         * @time: 2022/4/21 9:47
         */
        return "warehouse/materialEntryHistory";
    }

    @RequestMapping("handOurMaterial")
    public String handOurMaterial(@Param("id") Integer id, HttpServletRequest request) {
        WarehouseBean warehouseBean = warehouseBeanService.selectByPrimaryKey(id);
        request.setAttribute("ware", warehouseBean);
        return "warehouse/handOutMaterial";
    }

    @RequestMapping("materialOut")
    public String materialOut() {
        /**
         * @description: 领料出库
         * @return:  * @param
         * @author:
         * @time: 2022/4/21 14:48
         */
        return "warehouse/materialOut";
    }

    @RequestMapping("toProducePage")
    public String toProducePage() {
        /**
         * @description:成品库存
         * @return:  * @param
         * @author:
         * @time: 2022/4/24 14:14
         */
        return "warehouse/productPage";
    }

    @RequestMapping("selectProduceByParams")
    @ResponseBody
    public Map<String, Object> selectProduceByParams(WarehouseQuery query) {
        /**
         * @description: 产成品库存
         * @return:  * @param query
         * @author:
         * @time: 2022/4/24 17:42
         */
        return warehouseBeanService.selectProduceByParams(query);
    }

    @RequestMapping("outProduce")
    @ResponseBody
    public ResultInfo outProduce(Integer id){
        warehouseBeanService.outProduce(id);
      return  success("success");
    }
}
